package com.jlcloud.core.oauth2.exception;

import lombok.Getter;

import java.io.Serial;

/**
 * OAuth2通用异常
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
@Getter
public class OAuth2Exception extends RuntimeException {

	@Serial
	private static final long serialVersionUID = 1L;

	private final Oauth2ExceptionCode exceptionCode;

	public OAuth2Exception(String message) {
		super(message);
		this.exceptionCode = ExceptionCode.ACCESS_DENIED;
	}

	public OAuth2Exception(Oauth2ExceptionCode exceptionCode) {
		super(exceptionCode.getMessage());
		this.exceptionCode = exceptionCode;
	}

	public OAuth2Exception(Oauth2ExceptionCode exceptionCode, String message) {
		super(message);
		this.exceptionCode = exceptionCode;
	}

	public OAuth2Exception(Oauth2ExceptionCode exceptionCode, Throwable cause) {
		super(cause);
		this.exceptionCode = exceptionCode;
	}

	public OAuth2Exception(Oauth2ExceptionCode exceptionCode, String message, Throwable cause) {
		super(message, cause);
		this.exceptionCode = exceptionCode;
	}

	@Override
	public Throwable fillInStackTrace() {
		return this;
	}

}
